package com.weasing.res.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.weasing.res.dao.IWxAnswerDao;
import com.weasing.res.dao.IWxQuestionDao;
import com.weasing.res.domain.WxAnswer;
import com.weasing.res.domain.WxQuestion;
import com.weasing.res.service.IWxQuestionService;
import com.weasing.res.service.base.impl.BaseServiceImpl;
import com.weasing.res.vo.WxQuestionVO;

@Service
@Transactional
public class WxQuestionServiceImpl extends BaseServiceImpl<WxQuestion>
		implements IWxQuestionService {
	@Autowired
	private IWxQuestionDao wxQuestionDao;
	@Autowired
	private IWxAnswerDao wxAnswerDao;

	/**
	 * 通过ID查询WxQuestionVO(问题及答案分值)
	 * 
	 * @author minjun
	 * 
	 * @param id
	 */
	public WxQuestionVO findWxQuestionVOById(int id) {
		WxQuestionVO wqVO = null;
		WxQuestion wq = wxQuestionDao.findById(id);
		if (wq != null) {
			wqVO = new WxQuestionVO();
			wqVO.setWxQuestion(wq);
			List<WxAnswer> walist = wxAnswerDao.findWxAnswerByQid(wq.getId());
			if (walist.size() > 0) {
				wqVO.setWxAnswerList(walist);
			}
		}
		return wqVO;
	}

	@Override
	public List<WxQuestion> findWxQuestionByQid(int qid) {
		List<WxQuestion> list = wxQuestionDao.findWxQuestionByQid(qid);
		return list;
	}

}
